//
//  UIView+Gesture.h
//  高仿暴走斗图
//
//  Created by huangsongyao on 16/3/7.
//  Copyright © 2016年 huangsongyao. All rights reserved.
//

#import <UIKit/UIKit.h>

typedef NS_ENUM(NSUInteger, kGesturesType) {
    
    kGesturesTypeTapGestureRecognizer           = 0,    //点击
    kGesturesTypePinchGestureRecognizer         = 1,    //二指往內或往外拨动(放缩)
    kGesturesTypeRotationGestureRecognizer      = 2,    //旋转
    kGesturesTypeSwipeGestureRecognizer         = 3,    //滑动,快速移动
    kGesturesTypePanGestureRecognizer           = 4,    //拖移,慢速移动
    kGesturesTypeLongPressGestureRecognizer     = 5,    //长按
    
};

@interface UIView (Gesture)

/**
 *  快捷添加手势
 *
 *  @param gesturesType 手势类型
 *  @param action       关联方法
 *  @param delegate     委托对象
 *
 *  @return 手势对象
 */
+ (id)addGestureRecognizerWithGesturesType:(kGesturesType)gesturesType action:(SEL)action delegate:(id<UIGestureRecognizerDelegate>)delegate;

/**
 *  添加点击事件
 *
 *  @param action                  点击事件管理的方法
 *  @param delegate                委托对象
 *  @param numberOfTouchesRequired 手指数目
 *  @param numberOfTapsRequired    点击次数
 *
 *  @return 点击事件
 */
+ (UITapGestureRecognizer *)addTapGestureRecognizerWithAction:(SEL)action
                                                     delegate:(id<UIGestureRecognizerDelegate>)delegate
                                      numberOfTouchesRequired:(NSInteger)numberOfTouchesRequired
                                         numberOfTapsRequired:(NSInteger)numberOfTapsRequired;

/**
 *  添加放缩事件
 *
 *  @param action       放缩事件关联方法
 *  @param delegate     委托对象
 *  @param scale        相对位置的触点
 *
 *  @return 放缩事件
 */
+ (UIPinchGestureRecognizer *)addPinchGestureRecognizerWithAction:(SEL)action
                                                         delegate:(id<UIGestureRecognizerDelegate>)delegate
                                                            scale:(CGFloat)scale;

/**
 *  添加旋转事件
 *
 *  @param action   旋转事件的管理方法
 *  @param delegate 委托对象
 *  @param rotation 旋转角度
 *
 *  @return 旋转事件
 */
+ (UIRotationGestureRecognizer *)addRotationGestureRecognizerWithAction:(SEL)action
                                                               delegate:(id<UIGestureRecognizerDelegate>)delegate
                                                               rotation:(CGFloat)rotation;

/**
 *  添加滑动事件
 *
 *  @param action                  滑动事件关联方法
 *  @param delegate                委托对象
 *  @param numberOfTouchesRequired 手指数目
 *  @param direction               滑动放向
 *
 *  @return 滑动事件
 */
+ (UISwipeGestureRecognizer *)addSwipeGestureRecognizerWithAction:(SEL)action
                                                         delegate:(id<UIGestureRecognizerDelegate>)delegate
                                          numberOfTouchesRequired:(CGFloat)numberOfTouchesRequired
                                                        direction:(UISwipeGestureRecognizerDirection)direction;

/**
 *  添加移动事件
 *
 *  @param action                 移动事件关联方法
 *  @param delegate               委托对象
 *  @param minimumNumberOfTouches 移动事件中最小触屏的手指数目
 *  @param maximumNumberOfTouches 移动事件中最大触屏的手指数目
 *
 *  @return 移动事件
 */
+ (UIPanGestureRecognizer *)addPanGestureRecognizerWithAction:(SEL)action
                                                     delegate:(id<UIGestureRecognizerDelegate>)delegate
                                       minimumNumberOfTouches:(NSInteger)minimumNumberOfTouches
                                       maximumNumberOfTouches:(NSInteger)maximumNumberOfTouches;

/**
 *  添加长按事件
 *
 *  @param action                  长按事件的关联方法
 *  @param delegate                委托对象
 *  @param numberOfTapsRequired    点击几次开始长按
 *  @param numberOfTouchesRequired 长按事件的手指数目
 *  @param minimumPressDuration    长按事件的响应时间
 *  @param allowableMovement       手指长按移动的关联间距(类似button按下后平拖动的响应范围)
 *
 *  @return 长按事件
 */
+ (UILongPressGestureRecognizer *)addLongPressGestureRecognizerWithAction:(SEL)action
                                                                 delegate:(id<UIGestureRecognizerDelegate>)delegate
                                                     numberOfTapsRequired:(NSInteger)numberOfTapsRequired
                                                  numberOfTouchesRequired:(NSInteger)numberOfTouchesRequired
                                                     minimumPressDuration:(CFTimeInterval)minimumPressDuration
                                                        allowableMovement:(CGFloat)allowableMovement;

/**
 *  添加一个手势
 *
 *  @param action                   手势管理方法
 *  @param delegate                 委托对象
 *  @param gestureRecognizerClass   手势的类名
 *
 *  @return 返回一个手势对象
 */
+ (id)addGestureRecognizerWithAction:(SEL)action
                            delegate:(id<UIGestureRecognizerDelegate>)delegate
              gestureRecognizerClass:(Class)gestureRecognizerClass;

/**
 *  rac点击手势
 *
 *  @param delegate                delegate
 *  @param numberOfTouchesRequired 手指数目
 *  @param numberOfTapsRequired    点击次数
 *  @param block                   点击回调事件
 *
 *  @return UITapGestureRecognizer
 */
+ (UITapGestureRecognizer *)rad_addTapGestureRecognizerWithDelegate:(id<UIGestureRecognizerDelegate>)delegate numberOfTouchesRequired:(NSInteger)numberOfTouchesRequired numberOfTapsRequired:(NSInteger)numberOfTapsRequired selectBlock:(void(^)(id x))block;

/**
 *  rac滑动手势
 *
 *  @param delegate                delegate
 *  @param numberOfTouchesRequired 手指数目
 *  @param direction               滑动放向
 *  @param block                   点击回调事件
 *
 *  @return UISwipeGestureRecognizer
 */
+ (UISwipeGestureRecognizer *)rac_addSwipeGestureRecognizerWithDelegate:(id<UIGestureRecognizerDelegate>)delegate numberOfTouchesRequired:(CGFloat)numberOfTouchesRequired direction:(UISwipeGestureRecognizerDirection)direction swipeBlock:(void(^)(id x))block;

+ (UIPanGestureRecognizer *)rac_addPanGestureRecognizerWithDelegate:(id<UIGestureRecognizerDelegate>)delegate minimumNumberOfTouches:(NSInteger)minimumNumberOfTouches maximumNumberOfTouches:(NSInteger)maximumNumberOfTouches panBlock:(void(^)(id x))block;

@end
